<template>
	<div>
		<!-- 顶部选项卡 -->
		<scroll-view class="pagecontrol-top-scroll" scroll-x="true" scroll-with-animation
			:scroll-into-view="scrollInto">
			<view class="pagecontrol-top-title">
				<view v-for="(items, index) in itemsArr" :key="index" class="pagecontrol-top-text"
					@click="changeTab(index)" :id="'tab' + index">
					<view :class="tabIndex === index ? 'pagecontrol-top-selected' : 'pagecontrol-top-normal'">
						{{ items }}
					</view>
					<view class="pagecontrol-bottom-line"
						:class="tabIndex === index ? 'pagecontrol-bottom-line-show' : 'pagecontrol-bottom-line-visibility'">
					</view>
				</view>
			</view>
		</scroll-view>
		<!-- 内容 -->
		<swiper :duration="150" :current="tabIndex" @change="onChangeTab" :style="'height:' + scrollH + 'px;'">
			<swiper-item>
				<scroll-view scroll-y="true" show :style="'height:' + scrollH + 'px;'"  @scrolltolower="scrolltolower('customer')">
					<!--客户-->
					<view @click="handleDetailCustomer(item.customerId)" class="customer" v-for="(item,index) in customerList" :key="index">
						<view  style="display: flex;align-items: center;width: 100%;justify-content: space-between;">
							<span style="display: flex;align-items: center;">
								<view
									style="width: 40px;height: 40px;display: flex;justify-content: center;align-items: center;background-color: #ffeadb;border-radius: 50%;">
									{{item.customerName?item.customerName.slice(0,1):''}}
								</view>
								<view style="margin-left: 10px;">
									{{item.customerName}}
								</view>
							</span>
							<view>
								{{item.customerDistrictName||''}}
							</view>
						</view>
						<view style="display: flex;position: absolute;right: 10px;bottom: 10px;">
							<view @click.stop="editCustomer(item.customerId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								编辑</view>
							<view @click.stop="deleteCustomer(item.customerId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								删除</view>
						</view>
					</view>
					<uni-load-more status="more" :status="loadMoreStatus" @clickLoadMore="scrolltolower('customer')"></uni-load-more>
					<view style="height: 100px;"></view>
					
					<view class="position" @click="addCustomer" hover-class="buttonHover"
						style="position: fixed;margin: 0 auto;left:0;right:0;bottom:10px;width: 80px;height:30px;color:#ffffff;background-color:#bf5f09;border-radius: 4px;display:flex;justify-content: center;align-items: center;">
						新增&ensp;+
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<scroll-view scroll-y="true" show :style="'height:' + scrollH + 'px;'"  @scrolltolower="scrolltolower('project')">
					<!--项目-->
					<view @click="handleDetailProject(item.id)" class="carrier" v-for="(item,index) in projectList" :key="index">
						<view style="display: flex;align-items: center;flex: 3;">
							<view
								style="width: 40px;height: 40px;display: flex;justify-content: center;align-items: center;background-color: #ffeadb;border-radius: 50%;">
								{{item.projectName?item.projectName.slice(0,1):''}}
							</view>
							<view style="margin-left: 10px;">
								<view>{{item.projectName}}</view>
								<view style="color: #a5a5a5;font-size: 14px;">{{item.customer.customName}}</view>
							</view>
						</view>
						<view style="display: flex;align-items: center;">
							<view style="margin-left: 10px;position: relative;width: 100px;text-align: center;">
								<view v-if="item.settleType=='1'">现付{{item.spotPay}}元</view>
								<view v-else-if="item.settleType=='2'" >到付{{item.freightPay}}元</view>
								<view v-else-if="item.settleType=='3'" >欠付{{item.arrearsPay}}元</view>
								<view v-else-if="item.settleType=='4'" >回单付{{item.receiptPay}}元</view>
								<view v-else-if="item.settleType=='5'" >月结{{item.monthlyBalance}}元{{item.monthlyDays}}天</view>
								<view v-else-if="item.settleType=='7'" >混合付</view>
								<view style="color: #a5a5a5;font-size: 14px;">{{item.beginDate?item.beginDate:''}}</view>
								<!-- <view @click.stop="editProject(item.id)" hover-class="buttonHover"
									style="position: absolute;width: 40px;text-align: center;left:50%;transform: translateX(-50%);border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
									编辑</view> -->
							</view>
							<view style="margin-left: 10px;position: relative;width: 100px;text-align: center;">
								<view>{{item.districtName||''}}</view>
								<view style="color: #a5a5a5;font-size: 14px;">{{item.endDate?item.endDate:''}}</view>
								<!-- <view @click.stop="deleteProject(item.id)" hover-class="buttonHover"
									style="position: absolute;width: 40px;text-align: center;left:50%;transform: translateX(-50%);border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
									删除</view> -->
							</view>
						</view>
						<view style="display: flex;position: absolute;right: 10px;bottom: 10px;">
							<view @click.stop="editProject(item.id)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								编辑</view>
							<view @click.stop="deleteProject(item.id)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								删除</view>
						</view>
		
					</view>
					
					<uni-load-more status="more" :status="loadMoreStatus" @clickLoadMore="scrolltolower('project')"></uni-load-more>
					<view style="height: 100px;"></view>
					
					<view @click="addProject" hover-class="buttonHover"
						style="position: fixed;margin: 0 auto;left:0;right:0;bottom:10px;width: 80px;height:30px;color:#ffffff;background-color:#bf5f09;border-radius: 4px;display:flex;justify-content: center;align-items: center;">
						新增&ensp;+
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<scroll-view scroll-y="true" show :style="'height:' + scrollH + 'px;'"  @scrolltolower="scrolltolower('carrier')">
					<!--承运商-->
					<view @click="handleDetailCarrier(item.carrierId)" class="carrier" v-for="(item,index) in carrierList" :key="index">
						<view style="display: flex;align-items: center;flex: 3;">
							<view
								style="width: 40px;height: 40px;display: flex;justify-content: center;align-items: center;background-color: #ffeadb;border-radius: 50%;">
								{{item.carrierName?item.carrierName.slice(0,1):''}}
							</view>
							<view style="margin-left: 10px;">
								<view>{{item.carrierName}}</view>
								<view style="color: #a5a5a5;font-size: 14px;">{{item.contactPerson}}</view>
							</view>
						</view>
						<view style="display: flex;align-items: center;">
							<view style="margin-left: 10px;position: relative;width: 100px;text-align: center;">
								<view>{{carrierType[item.carrierType]}}</view>
								<view style="color: #a5a5a5;font-size: 14px;">{{item.createTime?item.createTime:''}}</view>
								<!-- <view @click.stop="editCarrier(item.carrierId)" hover-class="buttonHover"
									style="position: absolute;width: 40px;text-align: center;left:50%;transform: translateX(-50%);border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
									编辑</view> -->
							</view>
							<view style="margin-left: 10px;position: relative;width: 100px;text-align: center;">
								<view>{{item.businessDistrictName||''}}</view>
								<view style="color: #a5a5a5;font-size: 14px;">{{item.updateTime?item.updateTime:''}}</view>
								<!-- <view @click.stop="deleteCarrier(item.carrierId)" hover-class="buttonHover"
									style="position: absolute;width: 40px;text-align: center;left:50%;transform: translateX(-50%);border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
									删除</view> -->
							</view>
						</view>
						<view style="display: flex;position: absolute;right: 10px;bottom: 10px;">
							<view @click.stop="editCarrier(item.carrierId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								编辑</view>
							<view @click.stop="deleteCarrier(item.carrierId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								删除</view>
						</view>
					</view>
					<uni-load-more status="more" :status="loadMoreStatus" @clickLoadMore="scrolltolower('carrier')"></uni-load-more>
					<view style="height: 100px;"></view>
					
					<view @click="addCarrier" hover-class="buttonHover"
						style="position: fixed;margin: 0 auto;left:0;right:0;bottom:10px;width: 80px;height:30px;color:#ffffff;background-color:#bf5f09;border-radius: 4px;display:flex;justify-content: center;align-items: center;">
						新增&ensp;+
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<scroll-view scroll-y="true" show :style="'height:' + scrollH + 'px;'"  @scrolltolower="scrolltolower('driver')">
					<!--司机-->
					<view @click="handleDetailDriver(item.driverId)" class="driver" v-for="(item,index) in driverList" :key="index">
						<view style="display: flex;align-items: center;width: 100%;">
							<view
								style="width: 40px;height: 40px;display: flex;justify-content: center;align-items: center;background-color: #ffeadb;border-radius: 50%;">
								{{item.driverName?item.driverName.slice(0,1):''}}
							</view>
							<view class="round">
								<view style="display: flex;justify-content: space-between;">
									{{item.driverName}}
									<text>{{driverType_[item.driverType]}}</text>
									<text>{{item.sex=='0'?'男':'女'}}</text>
									<text>{{item.licenseType}}</text>
									<text style="width: 126px;text-align: center;">{{item.addressDistrictName||''}}</text>
								</view>
								<view style="color: #a5a5a5;font-size: 14px;display: flex;align-items: center;">
									{{item.phoneNumber.slice(0,3)+'****'+item.phoneNumber.slice(-4)}}
									<span v-if="item.accountStatus === null">
										<text style="margin-left: 10px;color:rgb(111, 111, 111);">未开通</text>
									</span>
									<span v-else>
										<text style="margin-left: 10px;color:rgb(0, 153, 255);">已开通</text>
										<text v-if="item.enableStatus=='1'"  style="margin-left: 10px;background-color: rgb(249,239,230);color: #bf5f09;padding: 2px;">启用</text>
										<text v-else  style="margin-left: 10px;background-color: rgb(214, 214, 214);color:#ffffff;padding: 2px;">禁用</text>
									</span>
									<!-- <text v-if="item.accountStatus === null" style="margin-left: 10px;color:rgb(111, 111, 111);">未开通</text>
									<text v-else style="margin-left: 10px;color:rgb(0, 153, 255);">已开通</text>
									<view v-if="item.enableStatus=='1'"  style="margin-left: 10px;background-color: rgb(249,239,230);color: #bf5f09;padding: 2px;">启用</view>
									<view v-else  style="margin-left: 10px;background-color: rgb(214, 214, 214);color:#ffffff;padding: 2px;">禁用</view> -->
								</view>
							</view>
						</view>
						<view style="display: flex;position: absolute;right: 10px;bottom: 10px;">
							<view v-if="item.enableStatus=='1'" @click.stop="banAccount(item)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid rgb(129, 129, 129);color:rgb(129, 129, 129);border-radius: 8px;font-size: 12px;">
								禁用</view>
							<view v-else @click.stop="enableAccount(item)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								启用</view>
							<view  @click.stop="resetPassword(item)" hover-class="buttonHover"
								style="margin-left: 10px;width: 60px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								重设密码</view>
							<view @click.stop="editDriver(item.driverId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								编辑</view>
							<view @click.stop="deleteDriver(item.driverId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								删除</view>
						</view>
		
					</view>
					<uni-load-more status="more" :status="loadMoreStatus" @clickLoadMore="scrolltolower('driver')"></uni-load-more>
					<view style="height: 100px;"></view>
					
					<view @click="addDriver" hover-class="buttonHover"
						style="position: fixed;margin: 0 auto;left:0;right:0;bottom:10px;width: 80px;height:30px;color:#ffffff;background-color:#bf5f09;border-radius: 4px;display:flex;justify-content: center;align-items: center;">
						新增&ensp;+
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<scroll-view scroll-y="true" show :style="'height:' + scrollH + 'px;'"  @scrolltolower="scrolltolower('car')">
					<!--车辆-->
					<view @click="handleDetailCar(item.carId)" class="driver" v-for="(item,index) in carList" :key="index">
						<view style="display: flex;align-items: center;width: 100%;">
							<view
								style="width: 40px;height: 40px;display: flex;justify-content: center;align-items: center;background-color: #ffeadb;border-radius: 50%;">
								{{item.licensePlate?item.licensePlate.slice(0,1):''}}
							</view>
							<view class="round">
								<view style="display: flex;justify-content: space-between;">
									{{item.licensePlate}}
									<text>{{carType[item.carType]||''}}</text>
									<!-- <text>空闲</text> -->
									<text>{{item.ownerLocationDistrictName||''}}</text>
								</view>
								<view style="color: #a5a5a5;font-size: 14px;">
									<text>{{item.carLength}}米</text>
									<text style="margin-left: 5px;">{{item.loadCapacity}}吨</text>
									<text style="margin-left: 5px;">{{item.volume}}方</text>
								</view>
							</view>
						</view>
						<view style="display: flex;position: absolute;right: 10px;bottom: 10px;">
							<view @click.stop="editCar(item.carId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								编辑</view>
							<view @click.stop="deleteCar(item.carId)" hover-class="buttonHover"
								style="margin-left: 10px;width: 40px;text-align: center;border: 1rpx solid #bf5f09;color:#bf5f09;border-radius: 8px;font-size: 12px;">
								删除</view>
						</view>
					</view>
					<uni-load-more status="more" :status="loadMoreStatus" @clickLoadMore="scrolltolower('car')"></uni-load-more>
					<view style="height: 100px;"></view>
					
					<view @click="addCar" hover-class="buttonHover"
						style="position: fixed;margin: 0 auto;left:0;right:0;bottom:10px;width: 80px;height:30px;color:#ffffff;background-color:#bf5f09;border-radius: 4px;display:flex;justify-content: center;align-items: center;">
						新增&ensp;+
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
		<!-- 司机启用禁用提示窗 -->
		<uni-popup ref="driverEnableDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="取消" :confirmText="'确认'+(enableAccountFlag?'启用':'禁用')" :title="(enableAccountFlag?'启用':'禁用')+'该账号？'"
				@confirm="driverEnableConfirm">
				<view :style="{'display': 'flex','color': (enableAccountFlag?'#bf5f09':'rgb(129, 129, 129)')}">
					<text>*确认{{enableAccountFlag?'启用':'禁用'}}当前司机-{{enableDriver.driverName}}的账号？*</text>
				</view>
			</uni-popup-dialog>
		</uni-popup>
		<!-- 司机重设密码提示窗 -->
		<uni-popup ref="resetPWDDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="取消" confirmText="确定" :title="'重置司机'+resetPwdDriver.driverName+'密码'"
				@confirm="resetPWDDialogConfirm" :before-close="true" @close="closeDialog('resetPWDDialog')">
					<uni-forms ref="form_resetDriverPWD" :modelValue="formData_resetDriverPWD" :rules="rules_resetDriverPWD" labelWidth="75px">
						<uni-forms-item label="新密码" required name="passwd">
							<uni-easyinput type="password" v-model="formData_resetDriverPWD.passwd" placeholder="请输入新密码" />
						</uni-forms-item>
						<!-- <uni-forms-item label="再次输入" required name="confirePwd">
							<uni-easyinput type="password" v-model="formData_resetDriverPWD.confirePwd" placeholder="请再次输入密码" />
						</uni-forms-item> -->
					</uni-forms>
			</uni-popup-dialog>
		</uni-popup>
		<!--引导页-->
		<guide :index="0"></guide>
	</div>
</template>

<script>
	import {resetPwd} from '@/api/login.js'
	import {
		getCustomerList,
		deleteCustomer
	} from '@/api/system/customer.js'
	import {
		getProjectList,
		deleteProject
	} from '@/api/system/project.js';
	import {
		getCarrierList,
		deleteCarrier
	} from '@/api/system/carrier.js';
	import {
		getDriverList,
		deleteDriver,
		updateDriverProfile
	} from '@/api/system/driver.js';
	import {
		getCarList,
		deleteCar
	} from '@/api/system/car.js';
	import {getDicts} from '@/api/system/dict.js'
	import guide from '@/components/guide/guide.vue'

	export default {
		components: {
			guide
		},
		data() {
			return {
				itemsArr: ['客户', '项目', '承运商', '司机', '车辆'],
				tabIndex: 0,
				scrollH: 700,
				scrollInto: '',
				customerList: [],
				projectList: [],
				carrierList: [],
				driverList: [],
				carList: [],
				//下拉框 ->司机类型
				driverType_:[],
				//下拉框 ->车型
				carType: [],
				//承运商类型
				carrierType:[],
				
				//启用司机账号标识
				enableAccountFlag:true,
				//当前启用、禁用司机对象
				enableDriver:{},
				//司机重设密码
				//当前重设密码司机对象
				resetPwdDriver:{},
				formData_resetDriverPWD:{
					dept:'',
					passwd:'',
					confirePwd:'' //二次密码
				},
				// 校验规则->重设密码
				rules_resetDriverPWD: {
					passwd: {
						rules: [{
							required: true,
							errorMessage: '密码不能为空',
						}]
					},
					// confirePwd: {
					// 	rules: [{
					// 		required: true,
					// 		errorMessage: '密码不能为空',
					// 	}]
					// },
				},

				//顾客列表页面大小
				pageNum_customer:10,
				//项目列表页面大小
				pageNum_project:10,
				//承运商列表页面大小
				pageNum_carrier:10,
				//司机列表页面大小
				pageNum_driver:10,
				//车辆列表页面大小
				pageNum_car:10,
				
				//上拉触底节流标识
				flag:true,
				//加载更多
				loadMoreStatus:'more'
			}
		},
		onLoad(e) {
			uni.getSystemInfo({
				success: res => {
					this.scrollH = res.windowHeight - 40;
				}
			});
		},
		created() {
			//加载客户列表
			this.getCustomerList()
		},
		methods: {
			// 触底的时候请求数据，即为上拉加载更多
			scrolltolower(name){
				this.loadMoreStatus='loading'
				if(this.flag){
				    setTimeout(()=>{
						if(name==='customer'){
							this.pageNum_customer+=10;
							this.getCustomerList()
						}
				        else if(name==='project'){
							this.pageNum_project+=10;
							this.getProjectList()
						}
						else if(name==='carrier'){
							this.pageNum_carrier+=10;
							this.getCarrierList()
						}
						else if(name==='driver'){
							this.pageNum_driver+=10;
							this.getDriverList()
						}
						else if(name==='car'){
							this.pageNum_car+=10;
							this.getCarList()
						}
				        this.flag = true;
				    },1000);
				}
				this.flag = false;
			},
			//接受提交后跳转的顶部导航栏位置
			otherFun(tabIndex) {
				if(tabIndex){
					uni.showLoading({
						title: '正在加载',
					})
					switch (tabIndex) {
						case '0':
							//加载客户列表
							this.getCustomerList()
							break;
						case '1':
							//加载项目列表
							this.getProjectList()
							break;
						case '2':
							//加载承运商列表
							this.getCarrierList()
							break;
						case '3':
							//加载司机列表
							this.getDriverList()
							break;
						case '4':
							//加载车辆列表
							this.getCarList()
							break;
						default:
							break;
					}
				}else{
					return
				}
			},
			//获取客户列表
			async getCustomerList() {
				await getCustomerList({pageNum:1,pageSize:this.pageNum_customer}).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						this.customerList = res.rows
						this.loadMoreStatus=res.rows.length===this.pageNum_customer?'more':'noMore'
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			//获取项目列表
			async getProjectList() {
				await getProjectList({pageNum:1,pageSize:this.pageNum_project}).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						this.projectList = res.rows
						this.loadMoreStatus=res.rows.length===this.pageNum_project?'more':'noMore'
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			//获取承运商列表
			async getCarrierList() {
				//加载承运商类型
				getDicts('carrier_type').then(res=>{
					res.data.forEach(item=>{
						this.carrierType[item.dictValue]=item.dictLabel
					})
				})
				await getCarrierList({pageNum:1,pageSize:this.pageNum_carrier}).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						this.carrierList = res.rows
						this.loadMoreStatus=res.rows.length===this.pageNum_carrier?'more':'noMore'
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			//获取司机列表
			async getDriverList() {
				//获取司机类型下拉框
				getDicts('driver_type').then(res=>{
					res.data.forEach(item=>{
						this.driverType_[item.dictValue]=item.dictLabel
					})
				})
				await getDriverList({pageNum:1,pageSize:this.pageNum_driver}).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						this.driverList = res.rows
						this.loadMoreStatus=res.rows.length===this.pageNum_driver?'more':'noMore'
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			//获取车辆列表
			async getCarList() {
				//获取车型信息
				getDicts('car_type').then(res=>{
					res.data.forEach(item=>{
						this.carType[item.dictValue]=item.dictLabel
					})
				})
				await getCarList({pageNum:1,pageSize:this.pageNum_car}).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						this.carList = res.rows
						this.loadMoreStatus=res.rows.length===this.pageNum_car?'more':'noMore'
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			// 切换选项
			changeTab(index) {
				if (this.tabIndex === index) {
					return;
				}
				this.tabIndex = index;
				// 滚动到指定元素
				this.scrollInto = 'tab' + index;
				switch (index) {
					case 0:
						//加载客户列表
						this.getCustomerList()
						break;
					case 1:
						//加载项目列表
						this.getProjectList()
						break;
					case 2:
						//加载承运商列表
						this.getCarrierList()
						break;
					case 3:
						//加载司机列表
						this.getDriverList()
						break;
					case 4:
						//加载车辆列表
						this.getCarList()
						break;
					default:
						break;
				}
			},
			// 监听滑动
			onChangeTab(e) {
				uni.showLoading({
					title: '正在加载',
				})
				// setTimeout(function() {
				// 	uni.hideLoading()
				// }, 500);
				this.changeTab(e.detail.current);
			},
			//新增客户
			addCustomer() {
				uni.navigateTo({
					url: '/pages-user/user/addCustomer/addCustomer'
				})
			},
			//编辑客户
			editCustomer(customerId) {
				uni.navigateTo({
					url: '/pages-user/user/addCustomer/addCustomer?customerId=' + customerId
				})
			},
			//删除客户
			deleteCustomer(customerId) {
				let that=this
				uni.showModal({
					title: '提示',
					content: '确定删除此条数据吗？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								title: '正在删除...',
							})
							deleteCustomer(customerId).then(res2 => {
								uni.hideLoading()
								if (res2.code == '200') {
									uni.showToast({
										icon: 'none',
										title: '删除成功'
									})
									
									//重新加载客户列表
									that.getCustomerList()
								} else {
									uni.showToast({
										icon: 'none',
										title: res2.msg
									})
								}
							})
						}
					}
				});

			},
			//客户详情
			handleDetailCustomer(customerId){
				uni.navigateTo({
					url: '/pages-user/user/addCustomer/detailsCustomer?customerId=' + customerId
				})
			},
			//新增项目
			addProject() {
				uni.navigateTo({
					url: '/pages-user/user/addProject/addProject'
				})
			},
			//编辑项目
			editProject(id) {
				uni.navigateTo({
					url: '/pages-user/user/addProject/addProject?id=' + id
				})
			},
			//删除项目
			deleteProject(id) {
				let that=this
				uni.showModal({
					title: '提示',
					content: '确定删除此条数据吗？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								title: '正在删除...',
							})
							deleteProject(id).then(res2 => {
								uni.hideLoading()
								if (res2.code == '200') {
									uni.showToast({
										icon: 'none',
										title: '删除成功'
									})
									
									//重新加载项目列表
									that.getProjectList()
								} else {
									uni.showToast({
										icon: 'none',
										title: res2.msg
									})
								}
							})
						}
					}
				});

			},
			//项目详情
			handleDetailProject(id){
				uni.navigateTo({
					url: '/pages-user/user/addProject/detailsProject?id=' + id
				})
			},
			//新增承运商
			addCarrier() {
				uni.navigateTo({
					url: '/pages-user/user/addCarrier/addCarrier'
				})
			},
			//编辑承运商
			editCarrier(carrierId) {
				uni.navigateTo({
					url: '/pages-user/user/addCarrier/addCarrier?carrierId=' + carrierId
				})
			},
			//删除承运商
			deleteCarrier(carrierId) {
				let that=this
				uni.showModal({
					title: '提示',
					content: '确定删除此条数据吗？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								title: '正在删除...',
							})
							deleteCarrier(carrierId).then(res2 => {
								uni.hideLoading()
								if (res2.code == '200') {
									uni.showToast({
										icon: 'none',
										title: '删除成功'
									})
									
									//重新加载承运商列表
									that.getCarrierList()
								} else {
									uni.showToast({
										icon: 'none',
										title: res2.msg
									})
								}
							})
						}
					}
				});
			
			},
			//承运商详情
			handleDetailCarrier(carrierId){
				uni.navigateTo({
					url: '/pages-user/user/addCarrier/detailsCarrier?carrierId=' + carrierId
				})
			},
			//启用司机账号
			enableAccount(item){
				if(item.accountStatus===null)
				{
					uni.showToast({
						icon: 'none',
						title: '当前账号未开通，无法启用'
					})
					return
				}
				this.enableAccountFlag=true
				this.enableDriver=item
				this.$refs.driverEnableDialog.open()
			},
			//禁用司机账号
			banAccount(item){
				if(item.accountStatus===null)
				{
					uni.showToast({
						icon: 'none',
						title: '当前账号未开通，无法禁用'
					})
					return
				}
				this.enableAccountFlag=false
				this.enableDriver=item
				this.$refs.driverEnableDialog.open()
			},
			//确认启用、禁用
			driverEnableConfirm(){
				uni.showLoading({
					title: '正在'+(this.enableAccountFlag?'启用':'禁用')+'...'
				})
				this.enableDriver.enableStatus=this.enableAccountFlag?'1':'0'
				delete this.enableDriver.openAccount; //删除开通账号属性
				updateDriverProfile(this.enableDriver).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						uni.showToast({
							title: (this.enableAccountFlag?'启用':'禁用')+'成功',
							icon: 'none'
						})
						//重新加载司机列表
						this.getDriverList()
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}	
				})
			},
			//手动关闭dialog
			closeDialog(type){
				this.$refs[type].close()
			},
			//重设司机密码
			resetPassword(item){
				if(item.openAccount=='0'||!item.openAccount)
				{
					uni.showToast({
						icon: 'none',
						title: '当前账号未开通，无法重置密码'
					})
					return
				}
				this.formData_resetDriverPWD.dept=''
				this.formData_resetDriverPWD.passwd=''
				this.formData_resetDriverPWD.confirePwd=''
				this.resetPwdDriver=item
				this.$refs.resetPWDDialog.open()
			},
			//确认重置密码
			resetPWDDialogConfirm(){
				this.$refs.form_resetDriverPWD.validate().then(res => {
					// if(this.formData_resetDriverPWD.passwd!==this.formData_resetDriverPWD.confirePwd)
					// {
					// 	uni.showToast({
					// 		icon: 'none',
					// 		title: '密码输入不一致'
					// 	})
					// 	return
					// }
					uni.showLoading({
						title: '正在修改...',
					})
					this.formData_resetDriverPWD.dept=this.resetPwdDriver.deptId;
					resetPwd(this.resetPwdDriver.phoneNumber,this.formData_resetDriverPWD).then(res => {
						uni.hideLoading()
						if (res.code == '200') {
							uni.showToast({
								title: '修改成功',
								icon: 'none'
							})
							//重新加载司机列表
							this.getDriverList()
							this.$refs.resetPWDDialog.close()
						} else {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						}	
					})
				}).catch(err => {
					uni.showToast({
						title: err[0].errorMessage,
						icon: 'none'
					})
				})
			},
			//新增司机
			addDriver() {
				uni.navigateTo({
					url: '/pages-user/user/addDriver/addDriver'
				})
			},
			//编辑司机
			editDriver(driverId) {
				uni.navigateTo({
					url: '/pages-user/user/addDriver/addDriver?driverId=' + driverId
				})
			},
			//删除司机
			deleteDriver(driverId) {
				let that=this
				uni.showModal({
					title: '提示',
					content: '确定删除此条数据吗？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								title: '正在删除...',
							})
							deleteDriver(driverId).then(res2 => {
								uni.hideLoading()
								if (res2.code == '200') {
									uni.showToast({
										icon: 'none',
										title: '删除成功'
									})
									
									//重新加载司机列表
									that.getDriverList()
								} else {
									uni.showToast({
										icon: 'none',
										title: res2.msg
									})
								}
							})
						}
					}
				});
			
			},
			//司机详情
			handleDetailDriver(driverId){
				uni.navigateTo({
					url: '/pages-user/user/addDriver/detailsDriver?driverId=' + driverId
				})
			},
			//新增车辆
			addCar() {
				uni.navigateTo({
					url: '/pages-user/user/addCar/addCar'
				})
			},
			//编辑车辆
			editCar(carId) {
				uni.navigateTo({
					url: '/pages-user/user/addCar/addCar?carId=' + carId
				})
			},
			//删除车辆
			deleteCar(carId) {
				let that=this
				uni.showModal({
					title: '提示',
					content: '确定删除此条数据吗？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								title: '正在删除...',
							})
							deleteCar(carId).then(res2 => {
								uni.hideLoading()
								if (res2.code == '200') {
									uni.showToast({
										icon: 'none',
										title: '删除成功'
									})
									
									//重新加载车辆列表
									that.getCarList()
								} else {
									uni.showToast({
										icon: 'none',
										title: res2.msg
									})
								}
							})
						}
					}
				});
			
			},
			//车辆详情
			handleDetailCar(carId){
				uni.navigateTo({
					url: '/pages-user/user/addCar/detailsCar?carId=' + carId
				})
			}
		},
	}
</script>

<style scoped>
	.pagecontrol-top-scroll {
		height: 40px;
		width: 100%;
		white-space: nowrap;
		box-sizing: border-box;
		border-bottom: 1rpx solid #ededed;
		background-color: #f8f8f8;
	}

	.pagecontrol-top-title {
		height: 100%;
		width: 100%;
		display: flex;
		justify-content: space-around;
	}

	.pagecontrol-top-text {
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		text-align: center;
	}

	.pagecontrol-top-normal {
		color: #656565;
		font-size: 16px;
	}

	.pagecontrol-top-selected {
		color: #000000;
		font-weight: bold;
		font-size: 16px;
	}

	.pagecontrol-bottom-line {
		width: 55px;
		height: 3px;
		margin-top: 8px;
		background-color: #bf5f09;
		border-radius: 11px;
	}

	.pagecontrol-bottom-line-show {
		visibility: visible;
	}

	.pagecontrol-bottom-line-visibility {
		visibility: hidden;
	}

	.customer {
		height: 60px;
		padding: 10px;
		display: flex;
		flex-direction: row;
		align-items: center;
		border-bottom: 1px solid #ededed;
		background-color: #ffffff;
		position: relative;
	}

	.carrier {
		height: 120px;
		padding: 10px;
		display: flex;
		flex-direction: row;
		align-items: center;
		border-bottom: 1px solid #ededed;
		background-color: #ffffff;
		position: relative;
	}

	.driver {
		height: 100px;
		padding: 10px;
		display: flex;
		flex-direction: row;
		align-items: center;
		border-bottom: 1px solid #ededed;
		background-color: #ffffff;
		position: relative;
	}

	.buttonHover {
		opacity: 0.6;
	}
	.round {
		margin-left: 10px;
		width: calc(100% - 50px);
	}
	::v-deep .uni-border-left{
	    border-left-color: #f0f0f0;
	    border-left-style: solid;
	    border-left-width: 1px;
	    background-color: rgb(157,81,38);
	    border-radius: 0 0 11px 0;
	    /* color: white; */
	}
	::v-deep .uni-button-color{
	    color: #ffffff;
	}
</style>